<?php
include('../../__global.php');
class aj_delComment extends ml_controller 
{
    private $_com_id;
    private $_rid;
    private $_uid;
    private $oComment;
    
    public function initParam()
    {
        $this->_com_id=intval($this->input('com_id',''));
        $this->_rid=$this->input('rid','');
        $this->oComment=new ml_model_dbComment();
        
    }
    public function checkParam(){
        
        //$this->check_referer();
        if(empty($this->_rid)){
            $this->api_output(ML_RCODE_PARAM);
        }
        
        if( !ml_tool_resid::is_resid($this->_rid)){
            $this->api_output(ML_RCODE_PARAM);
        }
        
        if(empty($this->_com_id)){
            $this->api_output(ML_RCODE_PARAM);
        }
        
        $this->_uid=ml_tool_resid::resid2uid($this->_rid);
        $rs=$this->oComment->getCommentById($this->_uid,$this->_com_id);
        $rs=$this->oComment->get_data();    
        $this->act_uid=$rs['act_uid'];
        if( !($this->__visitor['uid']== $rs['act_uid'] || $this->__visitor['uid'] == $this->_uid)  )
            $this->api_output(ML_RCODE_PARAM);
    }
    public function main()
    {
        $rs=$this->oComment->delCommentByCom_id($this->_com_id,$this->_uid,$this->act_uid);
        if(!$rs) 
            $this->api_output(ML_RCODE_BUSY);
        
        $oRedis =  new ml_model_rdsCount();    
        $oRedis -> decrCommentCount($this->_rid);
        ml_tool_actionlog::del_cmt($this->__visitor['uid'] , $this->_rid);
        $this->api_output(ML_RCODE_SUCC);
    }
    
}
new aj_delComment();


